<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login_controller extends CI_Controller{
     
 
     public function __construct()
       {
           parent::__construct();
           $this->load->library('session');
       }

    public function index()
	{
           $this->load->view('login');
	}
            
        public function proccess(){
            
          $this->load->model('login_model');
          
          $user= $this->input->post('user');
          $pass= $this->input->post('pass');
          
          $num = $this->login_model->checkuser($user,$pass);
         
        $total = count($num);
                if($total >0 ){
               
                    foreach($num as $u){
                       $sesion_data = array(
                           'id' => $u->id,
                           'alias' => $u->alias,
                           'name' => $u->name,
                           'id_rol' => $u->id_rol,
                           'status' => $u->status
                           );
                    }
               $this->session->set_userdata($sesion_data);
               redirect('/stock/', 'refresh');
                   
                }else{
                  redirect('','refresh');
                }
        
        }
        
      
    
}


?>